import time
from selenium import webdriver as wb
import pyautogui

def __login__(username,password):
    pyautogui.PAUSE=0.5#设置每个动作
    options = wb.ChromeOptions()
    options.add_experimental_option('excludeSwitches', ['enable-automation'])#切换到开发者模式
    browser = wb.Chrome(options=options)#打开浏览器
    browser.maximize_window()#窗口最大化
    browser.get('https://login.x315.com/user/login')
    time.sleep(5)
    pyautogui.moveTo(1150, 310)
    pyautogui.click()
    pyautogui.typewrite(username)#移动到用户名位置输入
    time.sleep(5)
    #pyautogui.moveRel(0, 40)  # 向下移动50//让光标以当前位置为原点，进行相对移动，就用pyautogui.moveRel()函数
    pyautogui.moveTo(1180, 360)
    pyautogui.click()
    pyautogui.typewrite(password)#移动到密码位置输入密码
    pyautogui.moveTo(1104, 420)#滑块位置开头
    moveToX_c = 1104 + 272
    pyautogui.dragTo(moveToX_c, 420, 2,button='left')#  按住鼠标左键，用2秒钟把鼠标拖拽到(100, 200)位置

    moveToX =1212
    moveToY =440+20
    pyautogui.moveTo(moveToX,moveToY)#移动到登录大致位置
    time.sleep(3)
    pyautogui.click()#点击登录按钮
    time.sleep(5)

    return browser#返回浏览器当前页面




if __name__=='__main__':
    browser= __login__('15095882178','tan15095882178')#用户名，密码




